﻿using System.Xml;
using System.Xml.Linq;

namespace Songhay.OpenXml.Models
{
    /// <summary>
    /// Provides the ability for XHTML to contain entities references.
    /// </summary>
    /// <remarks>
    /// This type is from Eric White, PowerTools for Open XML.
    /// 
    /// For more detail, see:
    /// 
    /// “Writing Entity References using LINQ to XML”
    /// http://blogs.msdn.com/b/ericwhite/archive/2010/01/21/writing-entity-references-using-linq-to-xml.aspx
    /// 
    /// </remarks>
    public class XEntity : XText
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="XEntity"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public XEntity(string value) : base(value) { }

        /// <summary>
        /// Writes this node to an <see cref="T:System.Xml.XmlWriter"/>.
        /// </summary>
        /// <param name="writer">An <see cref="T:System.Xml.XmlWriter"/> into which this method will write.</param>
        public override void WriteTo(XmlWriter writer)
        {
            writer.WriteEntityRef(this.Value);
        }
    }
}
